const { DataTypes } = require("sequelize");
const sequelize = require("./index");

const Shop = sequelize.define("shop", {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        allowNull: false,
        autoIncrement: true,
    },
    name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    desc: {
        type: DataTypes.TEXT,
        allowNull: false,
    },
    lng: {
        type: DataTypes.DOUBLE,
        allowNull: false,
    },
    lat: {
        type: DataTypes.DOUBLE,
        allowNull: false,
    },
    position: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    logo: {
        type: DataTypes.TEXT,
    },
    cover: {
        type: DataTypes.TEXT,
    },
    typeId: {
        type: DataTypes.INTEGER,
        allowNull: false,
    }
},{
    timestamps: false
});

Shop.associate = function ({
    ShopType,
    Product,
    Type,
                           }) {
    Shop.hasMany(ShopType)
    Shop.hasMany(Product)
    Shop.belongsTo(Type)
};

module.exports = Shop;
